/*-------------------------------------------------------------------------

***************** Modification History ***********************************
   @doc
   @module SDT.h - Shift Definition Table Header file |
   @end
   
$Log: /SoftPay/SPK2SIM/Source/Include/sdt.h $ 
 * 
 * 7     3/08/00 12:20p Page_k1
 * Remove unused fields.
 * 
 * 6     2/21/00 3:00p Jim_b4
 * Include file restructuring
 * 
 * 5     1/07/00 3:08p Gary_w2
 * Corrected for conditional compilation
 * 
 * 4     11/30/99 3:23p Kevin_v1
 * Removed File Name Message file usage
 * 
 * 3     11/19/99 10:04a Gary_w2
 * Moved shift definitions to define.h
 * 
 * 2     11/12/99 5:27p Gary_w2
 * Corrected shift reporting functionality
 * 
 * 1     11/08/99 4:19p Gary_w2
 * Initial Shift files
 * 
 * 1     7/19/99 5:32p Jim_b4
 * 
 * 1     7/19/99 4:10p Jim_b4
 * 
 * 2     6/09/99 11:18a Monique_b1
 * Change headers and file names for SP 2000
**************************************************************************

   Copyright (C) 1999 by VeriFone, Inc.

   All rights reserved.  No part of this software may be reproduced,
   transmitted, transcribed, stored in a retrieval system, or translated
   into any language or computer language, in any form or by any means,
   electronic, mechanical, magnetic, optical, chemical, manual or otherwise,
   without the prior written permission of VeriFone, Inc.

---------------------------------------------------------------------------*/

#ifndef VSSDT_H
#ifndef INTRAN_H
#define VSSDT_H

#include <fields.h>

#define SDT_FILE_NAME         "sdt.dat"

/*
 * The Shift Definition Table record structure, all character array fields are
 * left alligned, space filled on the right if it is of lesser length, and
 * NULL_CH terminated.
 */

typedef struct TagSDT_REC
{
    char    chShift;                        /* Shift Number */
    char    szStartTm[HHMM_SIZE + 1];   /* Shift Start Time */
    char    szEndTm[HHMM_SIZE + 1];     /* Shift End Time */
} SDT_REC;

#define SIZE_SDT_REC   sizeof(SDT_REC) + (sizeof(SDT_REC)%2)

// extern SDT_REC srSDTRec;


/* All total in STT_REC are Net */
typedef struct TagSTT_REC
{
	short inNetCount;                       /* Number of tran done: sale = +1, refund = +1, Void = -1, Adj. = +0 */
	long lnNetTotAmt;                      /* NetBase+NetTax+NetTip+NetCB+NetSurcharge */
	long lnNetBaseAmt;                     /* Net(SaleBase + VoidRefundBase - VoidSaleBase - RefundBase) */
	                                       /* for Adjustment:  +(TotalofTranAmt - TipAmt) - (OldTotalofTranAmt - OldTipAmt) */
	long lnNetTaxAmt;                      /* Net(Tax Amount) similar to NetBaseAmt Calc. except no adjustment */
	long lnNetTipAmt;                      /* Net(Tip Amount) similar to NetBaseAmt Calc. */
	                                       /* for Adjustment:  +(TipAmt) - (OldTipAmt) */
	long lnNetCashBack;                    /* Net(SaleCashBack - VoidSaleCashBack)   */
	long lnNetSurcharge;                   /* Net(SaleSurcharge + VoidRefundSurcharge - VoidSaleSurcharge - RefundSurcharge */
	long lnTipSale;                        /* (Base Amount of Transaction that has TipAmount != 0) - refund of (Base Amount of Transaction that has TipAmount != 0) */
	                                       /* for Adjustment: (Sale, in refund need to multiply by -1L */ 	       
 										/* from Tip to no Tip:  TipSale = -OldBaseAmount */
                                        /* if change from no Tip to Tip:  TipSale =  BaseAmount */
	                                       /* if change from Tip to Tip:     TipSale =  TotalTransAmount - OldTotalTransAmount */
	                                       /* in VOID Sale   TipSale = -BaseAmt */
	                                       /* in VOID Refund  TipSale = BaseAmt  */
} STT_REC;

#define SIZE_STT_REC    sizeof(STT_REC)

typedef struct TagSTT_KEY
{
    long   inRecNum;
   char   chShift; 
} STT_KEY;

#define SIZE_STT_KEY    sizeof(STT_KEY)

// extern STT_REC srSTTRec;

typedef struct TagSTT_SKEY 
{   
    int         (*compare_func) ();
    STT_KEY     sttKey;
} STT_SKEY;


typedef struct
{
    
    int  inCount;                          /* Number of tran done */
    long lnTotAmt;                         /* Base+Tax+Tip+CB+Surcharge */
    long lnBaseAmt;                        /* Base Amount */
    long lnTaxAmt;                         /* Tax amount */
    long lnTipAmt;                         /* Tip Amount */
    long lnCashBack;                       /* Cash Back amount  */
    long lnSurcharge;                      /* Surcharge amount  */
    long lnTipSale;                        /* TotalofTransaction (when tip > 0) */
} SHIFT_TOTS_REC;

#define SIZE_SHIFT_TOTS_REC     sizeof(SHIFT_TOTS_REC)

#ifdef SDT_C
void vdGetSTTFileName (char *pchSTTFileName);
int inOpenSTT (DB_FILE *psrDBFPtr, char *pchFName);
int inCloseSTT (DB_FILE *psrDBFPtr);
int inSTTCompareFn (STT_KEY *psrKey, STT_SKEY *MatchKey);
int inKeyReadSTT (DB_FILE *psrDBFPtr, STT_REC *psrRec, STT_KEY *psrKey, int inKeyIdx, long *plnRecNum);
int inGetKeySTTRec(DB_FILE *psrDBFPtr, STT_REC *psrRec, STT_KEY *psrKey, int inKeyIdx, long lnDBWhat);
int inSetSTTAmount (TRANSACTION_OBJECT *pobTran);
int inUpdateSTTRecord(TRANSACTION_OBJECT *pobTran, char chShift, int inCnt,
        long lnBase, long lnTax, long lnTip, long lnCsh, long lnSurcharge, long lnTipSale);
int inResetSTT (TRANSACTION_OBJECT *pobtran);
#else
 extern void vdGetSTTFileName (char *pchSTTFileName);
extern int inOpenSTT (DB_FILE *psrDBFPtr, char *pchFName);
extern int inCloseSTT (DB_FILE *psrDBFPtr);
extern int inSTTCompareFn (STT_KEY *psrKey, STT_SKEY *MatchKey);
extern int inKeyReadSTT (DB_FILE *psrDBFPtr, STT_REC *psrRec, STT_KEY *psrKey, int inKeyIdx, long *plnRecNum);
extern int inGetKeySTTRec(DB_FILE *psrDBFPtr, STT_REC *psrRec, STT_KEY *psrKey, int inKeyIdx, long lnDBWhat);
extern int inSetSTTAmount (TRANSACTION_OBJECT *pobTran);
extern int inUpdateSTTRecord(TRANSACTION_OBJECT *pobTran, char chShift, int inCnt,
        long lnBase, long lnTax, long lnTip, long lnCsh, long lnSurcharge, long lnTipSale);
extern int inResetSTT (TRANSACTION_OBJECT *pobtran);

#endif

#endif
#endif
